package org.itboys.mobile.service.mysql.web.selling;


import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.mobile.entity.mysql.TianJieWalletProduct;
import org.itboys.mobile.entity.mysql.selling.TianJieSellingReward;
import org.itboys.mysql.service.BaseMySqlService;
import org.itboys.param.PageResult;
import org.itboys.param.ParamUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 联系方式 ：empty90911@126.com
 * 描述：天街_金融_直销_奖励（等级或星级）_service
 */
@Service
public class TianJieSellingRewardService extends BaseMySqlService<TianJieSellingReward> {




    /**
     * 分页查询
     * @param request
     * @return
     */
    public PageResult<TianJieSellingReward> selectReward(HttpServletRequest request,Integer type){
        Map<String,Object> param =ParamUtil.packageMysqlPageParam(request,"name");
        param.put("type",type);
        return super.selectPage(param);
    }

    /**
     *  新增或保存
     * @param sellingReward
     */
    public void saveReward(TianJieSellingReward sellingReward){
        if(LongUtil.isNotZreo(sellingReward.getId())){
            super.update(sellingReward);
        }else{
            super.insert(sellingReward);
        }
    }


    /**
     * 单个查询
     * @param id
     * @return
     */
    public TianJieSellingReward findOne(Long id,Integer type){
        TianJieSellingReward sellingReward=null;
        if(LongUtil.isNotZreo(id)){
            sellingReward=super.find(id);
        }else{
            sellingReward=new TianJieSellingReward();
            sellingReward.setId(0l);
            sellingReward.setType(type);
        }
        return sellingReward;
    }






}
